﻿using FarmSmartSleep.Common.Domain.PM.select;
using FarmSmartSleep.Common.Dtos;
using FarmSmartSleep.Common.Infrastructure;
using MediatR;

namespace FarmSmartSleep.Organ.API.Application.ProductionManagement.SheepTransferCommands
{
    public class SheepTransferTypeSearchHander : IRequestHandler<SheepTransferTypeSearchCommand, Result>
    {

        private readonly IBaseRepository<SheepTransferType> baseRepository;


        public SheepTransferTypeSearchHander(IBaseRepository<SheepTransferType> baseRepository)
        {
            this.baseRepository = baseRepository;
        }


        /// <summary>
        /// 获取转舍类型
        /// </summary>
        /// <param name="request">获取转舍类型请求对象</param>
        /// <param name="cancellationToken"></param>
        /// <returns>返回转舍类型信息</returns>
        public async Task<Result> Handle(SheepTransferTypeSearchCommand request, CancellationToken cancellationToken)
        {
            try
            {
                var result = new Result();
                var list = baseRepository.GetAll().ToList();
                result.Data =  list;
                return result;
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
